#include <mpi.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	char mensagem[12];
	int id, nproc, i;
	MPI_Status status;
	MPI_Init(&argc, &argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &id);
	MPI_Comm_size(MPI_COMM_WORLD, &nproc);
	if(id == 0)
	{
		strcpy(mensagem, "Ola Mundo");
		for(i = 1; i < nproc; i++)
		{
			MPI_Send(&mensagem, 12, MPI_CHAR, i, 100, MPI_COMM_WORLD);
		}
	}
	else
	{
		MPI_Recv(&mensagem, 12, MPI_CHAR, 0, 100, MPI_COMM_WORLD, &status);
	}
	printf("Sou o processo %i: %s \n", id, mensagem);
	MPI_Finalize();
}
